package com.shop.order.controller;

import com.api.openfeign.dto.ProductInfoDto;
import com.shop.order.config.LoaclDateConfing;

import com.shop.order.model.OrderMaster;
import com.shop.order.repository.OrderMasterRepository;
import com.shop.order.service.OrderServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;

@RestController
@RequestMapping("order")
@Slf4j
@RefreshScope
public class IndexController {


    @Autowired
    private OrderServiceImpl orderService;
    @RequestMapping("index")
    public ProductInfoDto index(@RequestParam String orderId) {
        //OrderMaster orderMaster = orderMasterRepository.findById(orderId).orElse(null);
        //log.info("orderId:{} {}", orderId,orderMaster);
        ProductInfoDto productInfoDto = orderService.QueryOrder(orderId);
        return productInfoDto;
    }

//    @Value("${format.time}")
//    private String no;
//
//    @Value("${format.aaa}")
//    private String aaa;

    @Autowired
    private LoaclDateConfing loaclDateConfing;
    @RequestMapping("now")
    public LoaclDateConfing now() {
        //log.info("time: {} aaa:{}",loaclDateConfing.time, loaclDateConfing.aaa);
        //LocalDateTime.now().format(LocalDateTime.ofInstant(Instant.ofEpochMilli(no), ZoneId.systemDefault()));
        return loaclDateConfing;
    }
}
